package xyz.wanwanwan.www.hrm._02_work_queue;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import xyz.wanwanwan.www.hrm.util.ConnectionUtil;

//1.创建连接
    //2.创建通道
    //3.创建交换机
    //4.创建队列
    //5.准备消息
    //6.发送消息
public class Sender {
    //队列名
    public static final String MQ_WORKQUEUE_QUEUE = "mq_workqueue_queue";
    public static void main(String[] args) throws Exception {
        //1.创建连接
        Connection connection = ConnectionUtil.getConnection();
        //2.创建通道
        Channel channel = connection.createChannel();
        //3.创建交换机
        //4.创建队列
        //队列名称
        //是否持久化
        //队列是否独占此连接
        //队列不再使用时是否自动删除此队列
        //队列参数
        channel.queueDeclare(MQ_WORKQUEUE_QUEUE,true,false,false,null);
        //5.准备消息
        String message = "hello rabbitmq!!!!!!!";
        //6.发送消息
        channel.basicPublish("",MQ_WORKQUEUE_QUEUE,null,message.getBytes());
        System.out.println("发送成功了");
    }


}
